﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.mainmenu {
    import reprise.ui.*;
    import flash.events.*;
    import reprise.controls.*;
    import __AS3__.vec.*;
    import net.wooga.pets.utils.*;

    public class ShopTabDisplay extends UIComponent {

        protected var _scrollPane:ScrollPane;
        protected var _blocker:UIComponent;
        protected var _blockerLabel:Label;
        protected var _category:String;
        protected var _toggleCashBoxButton:SimpleButton;
        protected var _itemsPool:Vector.<ShopItemDisplay>;
        protected var _blockerButton:LabelButton;

        public function ShopTabDisplay(){
            this._itemsPool = new Vector.<ShopItemDisplay>();
            super();
        }
        public function createItem(_arg1:String, _arg2:String, _arg3:String, _arg4:int, _arg5:int, _arg6:int, _arg7:Boolean, _arg8:int, _arg9:String="", _arg10:Boolean=false):ShopItemDisplay{
            var _local12:ShopPlaceholderScrollItem;
            var _local11:ShopItemDisplay = this.getItemFromPool(_arg1);
            if (!_local11){
                _local11 = new ShopItemDisplay(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg9, _arg10);
                _local11.setData(_arg1);
                this._itemsPool.push(_local11);
            };
            if (_arg8 == 1){
                _local12 = this.getPlaceHolderWithFreeTopSlot();
                _local12.addItemToTopSlot(_local11);
            } else {
                _local12 = this.getPlaceHolderWithFreeBottomSlot();
                _local12.addItemToBottomSlot(_local11);
            };
            return (_local11);
        }
        private function getItemFromPool(_arg1:String):ShopItemDisplay{
            var _local2:ShopItemDisplay;
            for each (_local2 in this._itemsPool) {
                if (_local2.type == _arg1){
                    return (_local2);
                };
            };
            return (null);
        }
        public function scrollToShopItem(_arg1:ShopItemDisplay):void{
            var _local2:int = this.getPlaceHolderIndexOfItem(_arg1);
            this._scrollPane.scrollToIndex(_local2);
        }
        public function gotoIndex(_arg1:int):void{
            this._scrollPane.scrollToIndex(_arg1, false);
        }
        public function setBlockerLabel(_arg1:String, _arg2:String):void{
            this._blockerLabel.setLabel(_arg1);
            this.blockerButton.setLabel(_arg2);
        }
        public function showBlockLayer():void{
            this._blocker.addCSSClass("active");
        }
        public function hideBlockLayer():void{
            this._blocker.removeCSSClass("active");
        }
        public function getAllItems():Vector.<ShopItemDisplay>{
            return (this._itemsPool);
        }
        public function removeItemByType(_arg1:String):ShopItemDisplay{
            var _local2:ShopItemDisplay;
            for each (_local2 in this._itemsPool) {
                if (((_local2) && ((_local2.type == _arg1)))){
                    this._itemsPool.splice(this._itemsPool.indexOf(_local2), 1);
                    _local2.remove();
                    return (_local2);
                };
            };
            return (null);
        }
        public function getItemByType(_arg1:String):ShopItemDisplay{
            var _local2:ShopItemDisplay;
            for each (_local2 in this._itemsPool) {
                if (((_local2) && ((_local2.type == _arg1)))){
                    return (_local2);
                };
            };
            return (null);
        }
        public function get category():String{
            return (this._category);
        }
        public function set category(_arg1:String):void{
            this._category = _arg1;
        }
        public function showTrashButton():void{
            this._toggleCashBoxButton.removeCSSClass("boxIcon");
            this._toggleCashBoxButton.addCSSClass("trashIcon");
        }
        public function showBoxButton():void{
            this._toggleCashBoxButton.removeCSSClass("trashIcon");
            this._toggleCashBoxButton.addCSSClass("boxIcon");
        }
        public function isScrolling():Boolean{
            return (this._scrollPane.isScrolling);
        }
        public function getColumnOfItem(_arg1:ShopItemDisplay):int{
            var _local3:ShopPlaceholderScrollItem;
            var _local2:Array = getElementsByClassName("customizePlaceholderScrollItem");
            var _local4:int;
            while (_local4 < _local2.length) {
                _local3 = _local2[_local4];
                if (_local3.containsItem(_arg1)){
                    return (_local4);
                };
                _local4++;
            };
            return (-1);
        }
        override protected function createChildren():void{
            this._toggleCashBoxButton = SimpleButton(addComponent("shopButton", null, SimpleButton));
            this.showBoxButton();
            var _local1:SimpleButton = SimpleButton(addComponent("shopButton cashButton", null, SimpleButton));
            addComponent("verticalWhiteLine");
            this._scrollPane = ScrollPane(addChild(new ScrollPane(7)));
            var _local2:int;
            while (_local2 < this._scrollPane.numberOfVisibleItems) {
                this._scrollPane.addItem(new ShopPlaceholderScrollItem());
                _local2++;
            };
            this._blocker = addComponent("blocker");
            this._blockerLabel = RepriseUtils.addLabel(this._blocker, "blockerLabel myriadProFont");
            this._blockerButton = RepriseUtils.addLabelButton(this._blocker, "rectButton", null, null, null, "showcardGothicFontOutline");
        }
        protected function getPlaceHolderWithFreeTopSlot():ShopPlaceholderScrollItem{
            var _local2:ShopPlaceholderScrollItem;
            var _local1:Array = getElementsByClassName("customizePlaceholderScrollItem");
            for each (_local2 in _local1) {
                if (_local2.hasTopFreeSlot()){
                    return (_local2);
                };
            };
            return (this.createPlaceHolderScrollItem());
        }
        private function getPlaceHolderWithFreeBottomSlot():ShopPlaceholderScrollItem{
            var _local2:ShopPlaceholderScrollItem;
            var _local1:Array = getElementsByClassName("customizePlaceholderScrollItem");
            for each (_local2 in _local1) {
                if (_local2.hasBottomFreeSlot()){
                    return (_local2);
                };
            };
            return (this.createPlaceHolderScrollItem());
        }
        protected function createPlaceHolderScrollItem():ShopPlaceholderScrollItem{
            var _local1:ShopPlaceholderScrollItem = new ShopPlaceholderScrollItem();
            _local1.setData(this._scrollPane.items.length);
            this._scrollPane.addItem(_local1);
            _local1.addEventListener(ShopPlaceholderScrollItem.EMPTY, this.placeHolder_empty);
            return (_local1);
        }
        private function placeHolder_empty(_arg1:Event):void{
            var _local2:ShopPlaceholderScrollItem = ShopPlaceholderScrollItem(_arg1.target);
            _local2.removeEventListener(ShopPlaceholderScrollItem.EMPTY, this.placeHolder_empty);
            var _local3:Array = getElementsByClassName("customizePlaceholderScrollItem");
            var _local4:int = _local3.length;
            if (_local4 > this._scrollPane.numberOfVisibleItems){
                this._scrollPane.removeItem(_local2);
            };
        }
        private function getPlaceHolderIndexOfItem(_arg1:ShopItemDisplay):int{
            var _local3:ShopPlaceholderScrollItem;
            var _local2:Array = getElementsByClassName("customizePlaceholderScrollItem");
            for each (_local3 in _local2) {
                if (_local3.containsItem(_arg1)){
                    log(_local3.data());
                    return (_local3.data());
                };
            };
            return (-1);
        }
        public function highlightIconByType(_arg1:String):void{
            var _local2:ShopItemDisplay = this.getItemByType(_arg1);
            ((_local2) && (_local2.playHighlight()));
        }
        public function get blockerButton():LabelButton{
            return (this._blockerButton);
        }

    }
}//package net.wooga.pets.views.components.mainmenu 
